package com.mzm.domain;

import java.util.Arrays;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.IndexColumn;

@Entity(name = "Recommendation")
@Table(name = "RECOMMENDATION")
public class Recommendation extends BaseEntity {

	@Column(name = "RCOMMENDER_NAME")
	private String recommenderName;

	@Column(name = "SHEET_NUM")
	private Integer sheetNumber;

	@Column(name = "GRADE")
	private Integer grade;

	@Column(name = "GRADE_RANGE")
	private Integer gradeRange;

	@Column(name = "CONTENT")
	private String content;

	@Column(name = "REMARKS")
	private String remarks;

	@Column(name = "PRICE")
	private Integer price;

	@Column(name = "CURRENCY")
	private String currency;

	@ManyToOne
	@Cascade({ CascadeType.REFRESH })
	@JoinColumn(name = "PRODUCT_INFO_ID")
	private ProductInfo productInfo;

	@ManyToOne
	@Cascade({ CascadeType.REFRESH })
	@JoinColumn(name = "MEDIA_INFO_ID")
	private MediaInfo mediaInfo;


	@ElementCollection(fetch = FetchType.EAGER)
	@Cascade({ CascadeType.ALL })
	@JoinTable(name = "RECOMMENDATION_KEYWORDS", joinColumns = { @JoinColumn(name = "RECOMMENDATION_ID") })
	@IndexColumn(name = "INDX")
	@Column(name = "KEYWORD")
	private List<String> keywords;


	public String getRecommenderName() {
		return recommenderName;
	}

	public void setRecommenderName(String recommenderName) {
		this.recommenderName = recommenderName;
	}

	public Integer getSheetNumber() {
		return sheetNumber;
	}

	public void setSheetNumber(Integer sheetNumber) {
		this.sheetNumber = sheetNumber;
	}

	public Integer getGrade() {
		return grade;
	}

	public void setGrade(Integer grade) {
		this.grade = grade;
	}

	public Integer getGradeRange() {
		return gradeRange;
	}

	public void setGradeRange(Integer gradeRange) {
		this.gradeRange = gradeRange;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public Integer getPrice() {
		return price;
	}

	public void setPrice(Integer price) {
		this.price = price;
	}

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	public ProductInfo getProductInfo() {
		return productInfo;
	}

	public void setProductInfo(ProductInfo productInfo) {
		this.productInfo = productInfo;
	}

	public MediaInfo getMediaInfo() {
		return mediaInfo;
	}

	public void setMediaInfo(MediaInfo mediaInfo) {
		this.mediaInfo = mediaInfo;
	}

	public List<String> getKeywords() {
		return keywords;
	}

	public void setKeywords(List<String> keywords) {
		this.keywords = keywords;
	}

	public void setKeywords(String ... keywords) {
		this.keywords = Arrays.asList(keywords);
	}

}
